<template>
  <div class="p-2">
    <transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
      <div v-show="showSearch" class="mb-[10px]">
        <el-card shadow="hover">
          <el-form ref="queryFormRef" :model="queryParams" :inline="true" label-width="145">
            <div :style="{ 'height': `${isexpand ? 'auto' : '100px'}`, 'overflow': 'hidden' }">
              <el-form-item label="案件号" prop="claimId">
                <el-input v-model="queryParams.claimId" placeholder="请输入案件号" clearable @keyup.enter="handleQuery" />
              </el-form-item>
              <el-form-item label="业务来源" prop="businessSource">
                <el-input v-model="queryParams.businessSource" placeholder="请输入业务来源" clearable @keyup.enter="handleQuery" />
              </el-form-item>
              <el-form-item label="京东报案号" prop="jdReportId">
                <el-input v-model="queryParams.jdReportId" placeholder="请输入京东报案号" clearable @keyup.enter="handleQuery" />
              </el-form-item>
              <el-form-item label="报案时间" prop="reportTime">
                <el-input v-model="queryParams.reportTime" placeholder="请输入报案时间" clearable @keyup.enter="handleQuery" />
              </el-form-item>
              <el-form-item label="出险时间" prop="occurrenceTime">
                <el-input v-model="queryParams.occurrenceTime" placeholder="请输入出险时间" clearable @keyup.enter="handleQuery" />
              </el-form-item>
              <el-form-item label="结案时间" prop="closeTime">
                <el-input v-model="queryParams.closeTime" placeholder="请输入结案时间" clearable @keyup.enter="handleQuery" />
              </el-form-item>
              <el-form-item label="报案方式" prop="reportMethod">
                <el-input v-model="queryParams.reportMethod" placeholder="请输入报案方式" clearable @keyup.enter="handleQuery" />
              </el-form-item>
              <el-form-item label="物损程度" prop="damageDegree">
                <el-input v-model="queryParams.damageDegree" placeholder="请输入物损程度" clearable @keyup.enter="handleQuery" />
              </el-form-item>
              <el-form-item label="一级原因" prop="firstLevelReason">
                <el-input v-model="queryParams.firstLevelReason" placeholder="请输入一级原因" clearable @keyup.enter="handleQuery" />
              </el-form-item>
              <el-form-item label="二级原因" prop="secondLevelReason">
                <el-input v-model="queryParams.secondLevelReason" placeholder="请输入二级原因" clearable @keyup.enter="handleQuery" />
              </el-form-item>
              <el-form-item label="报案人" prop="reporter">
                <el-input v-model="queryParams.reporter" placeholder="请输入报案人" clearable @keyup.enter="handleQuery" />
              </el-form-item>
              <el-form-item label="报案人电话" prop="reporterPhone">
                <el-input v-model="queryParams.reporterPhone" placeholder="请输入报案人电话" clearable @keyup.enter="handleQuery" />
              </el-form-item>
              <el-form-item label="寄件人" prop="sender">
                <el-input v-model="queryParams.sender" placeholder="请输入寄件人" clearable @keyup.enter="handleQuery" />
              </el-form-item>
              <el-form-item label="寄件人电话" prop="senderPhone">
                <el-input v-model="queryParams.senderPhone" placeholder="请输入寄件人电话" clearable @keyup.enter="handleQuery" />
              </el-form-item>
              <el-form-item label="寄件地址" prop="senderAddress">
                <el-input v-model="queryParams.senderAddress" placeholder="请输入寄件地址" clearable @keyup.enter="handleQuery" />
              </el-form-item>
              <el-form-item label="赔付方式" prop="paymentMethod">
                <el-input v-model="queryParams.paymentMethod" placeholder="请输入赔付方式" clearable @keyup.enter="handleQuery" />
              </el-form-item>
              <el-form-item label="保单号" prop="policyId">
                <el-input v-model="queryParams.policyId" placeholder="请输入保单号" clearable @keyup.enter="handleQuery" />
              </el-form-item>
              <el-form-item label="保单起期" prop="policyStartTime">
                <el-input v-model="queryParams.policyStartTime" placeholder="请输入保单起期" clearable @keyup.enter="handleQuery" />
              </el-form-item>
              <el-form-item label="保单止期" prop="policyEndTime">
                <el-input v-model="queryParams.policyEndTime" placeholder="请输入保单止期" clearable @keyup.enter="handleQuery" />
              </el-form-item>
              <el-form-item label="延保订单号" prop="extendedWarrantyOrderId">
                <el-input v-model="queryParams.extendedWarrantyOrderId" placeholder="请输入延保订单号" clearable @keyup.enter="handleQuery" />
              </el-form-item>
              <el-form-item label="商家ID" prop="merchantId">
                <el-input v-model="queryParams.merchantId" placeholder="请输入商家ID" clearable @keyup.enter="handleQuery" />
              </el-form-item>
              <el-form-item label="店铺ID" prop="shopId">
                <el-input v-model="queryParams.shopId" placeholder="请输入店铺ID" clearable @keyup.enter="handleQuery" />
              </el-form-item>
              <el-form-item label="店铺名称" prop="shopName">
                <el-input v-model="queryParams.shopName" placeholder="请输入店铺名称" clearable @keyup.enter="handleQuery" />
              </el-form-item>
              <el-form-item label="险种名称" prop="insuranceName">
                <el-input v-model="queryParams.insuranceName" placeholder="请输入险种名称" clearable @keyup.enter="handleQuery" />
              </el-form-item>
              <el-form-item label="主商品订单号" prop="mainOrderId">
                <el-input v-model="queryParams.mainOrderId" placeholder="请输入主商品订单号" clearable @keyup.enter="handleQuery" />
              </el-form-item>
              <el-form-item label="主商品下单时间" prop="mainOrderCreateTime">
                <el-input v-model="queryParams.mainOrderCreateTime" placeholder="请输入主商品下单时间" clearable @keyup.enter="handleQuery" />
              </el-form-item>
              <el-form-item label="主商品出库时间" prop="mainOrderOutboundTime">
                <el-input v-model="queryParams.mainOrderOutboundTime" placeholder="请输入主商品出库时间" clearable @keyup.enter="handleQuery" />
              </el-form-item>
              <el-form-item label="主商品完成时间" prop="mainOrderCompleteTime">
                <el-input v-model="queryParams.mainOrderCompleteTime" placeholder="请输入主商品完成时间" clearable @keyup.enter="handleQuery" />
              </el-form-item>
              <el-form-item label="主商品名称" prop="mainCommodityName">
                <el-input v-model="queryParams.mainCommodityName" placeholder="请输入主商品名称" clearable @keyup.enter="handleQuery" />
              </el-form-item>
              <el-form-item label="主商品SKU" prop="mainCommoditySku">
                <el-input v-model="queryParams.mainCommoditySku" placeholder="请输入主商品SKU" clearable @keyup.enter="handleQuery" />
              </el-form-item>
              <el-form-item label="主商品IMEI设备标识" prop="mainCommodityImei">
                <el-input v-model="queryParams.mainCommodityImei" placeholder="请输入主商品IMEI设备标识" clearable @keyup.enter="handleQuery" />
              </el-form-item>
              <el-form-item label="主商品品牌" prop="brand">
                <el-input v-model="queryParams.brand" placeholder="请输入主商品品牌" clearable @keyup.enter="handleQuery" />
              </el-form-item>
              <el-form-item label="主商品型号" prop="model">
                <el-input v-model="queryParams.model" placeholder="请输入主商品型号" clearable @keyup.enter="handleQuery" />
              </el-form-item>
              <el-form-item label="主商品一级类目" prop="firstCategoryName">
                <el-input v-model="queryParams.firstCategoryName" placeholder="请输入主商品一级类目" clearable @keyup.enter="handleQuery" />
              </el-form-item>
              <el-form-item label="主商品二级类目" prop="secondCategoryName">
                <el-input v-model="queryParams.secondCategoryName" placeholder="请输入主商品二级类目" clearable @keyup.enter="handleQuery" />
              </el-form-item>
              <el-form-item label="主商品三级类目" prop="thirdCategoryName">
                <el-input v-model="queryParams.thirdCategoryName" placeholder="请输入主商品三级类目" clearable @keyup.enter="handleQuery" />
              </el-form-item>
              <el-form-item label="险种编码" prop="insuranceCode">
                <el-input v-model="queryParams.insuranceCode" placeholder="请输入险种编码" clearable @keyup.enter="handleQuery" />
              </el-form-item>
              <el-form-item label="险种编码名称" prop="insuranceCodeName">
                <el-input v-model="queryParams.insuranceCodeName" placeholder="请输入险种编码名称" clearable @keyup.enter="handleQuery" />
              </el-form-item>
              <el-form-item label="评星" prop="rating">
                <el-input v-model="queryParams.rating" placeholder="请输入评星" clearable @keyup.enter="handleQuery" />
              </el-form-item>
              <el-form-item label="交付商名称" prop="repairerName">
                <el-input v-model="queryParams.repairerName" placeholder="请输入交付商名称" clearable @keyup.enter="handleQuery" />
              </el-form-item>
              <el-form-item label="门店名称" prop="storeName">
                <el-input v-model="queryParams.storeName" placeholder="请输入门店名称" clearable @keyup.enter="handleQuery" />
              </el-form-item>
              <el-form-item label="派单时间" prop="dispatchTime">
                <el-input v-model="queryParams.dispatchTime" placeholder="请输入派单时间" clearable @keyup.enter="handleQuery" />
              </el-form-item>
              <el-form-item label="接单时间" prop="acceptTime">
                <el-input v-model="queryParams.acceptTime" placeholder="请输入接单时间" clearable @keyup.enter="handleQuery" />
              </el-form-item>
              <el-form-item label="客户寄送时间" prop="customerSendTime">
                <el-input v-model="queryParams.customerSendTime" placeholder="请输入客户寄送时间" clearable @keyup.enter="handleQuery" />
              </el-form-item>
              <el-form-item label="快递单号" prop="expressNo">
                <el-input v-model="queryParams.expressNo" placeholder="请输入快递单号" clearable @keyup.enter="handleQuery" />
              </el-form-item>
              <el-form-item label="接机时间" prop="receiveMachineTime">
                <el-input v-model="queryParams.receiveMachineTime" placeholder="请输入接机时间" clearable @keyup.enter="handleQuery" />
              </el-form-item>
              <el-form-item label="方案提交时间" prop="planSubmitTime">
                <el-input v-model="queryParams.planSubmitTime" placeholder="请输入方案提交时间" clearable @keyup.enter="handleQuery" />
              </el-form-item>
              <el-form-item label="履约完成时间" prop="performanceCompleteTime">
                <el-input v-model="queryParams.performanceCompleteTime" placeholder="请输入履约完成时间" clearable @keyup.enter="handleQuery" />
              </el-form-item>
              <el-form-item label="采购渠道" prop="procurementChannel">
                <el-input v-model="queryParams.procurementChannel" placeholder="请输入采购渠道" clearable @keyup.enter="handleQuery" />
              </el-form-item>
              <el-form-item label="新机订单号" prop="newMachineOrderId">
                <el-input v-model="queryParams.newMachineOrderId" placeholder="请输入新机订单号" clearable @keyup.enter="handleQuery" />
              </el-form-item>
              <el-form-item label="归档时间" prop="fileTime">
                <el-input v-model="queryParams.fileTime" placeholder="请输入归档时间" clearable @keyup.enter="handleQuery" />
              </el-form-item>
              <el-form-item label="残值是否回收" prop="isResidualRecovered">
                <el-input v-model="queryParams.isResidualRecovered" placeholder="请输入残值是否回收" clearable @keyup.enter="handleQuery" />
              </el-form-item>
              <el-form-item label="赔款是否支付" prop="isClaimPaid">
                <el-input v-model="queryParams.isClaimPaid" placeholder="请输入赔款是否支付" clearable @keyup.enter="handleQuery" />
              </el-form-item>
              <el-form-item label="残值是否拍卖" prop="isResidualAuctioned">
                <el-input v-model="queryParams.isResidualAuctioned" placeholder="请输入残值是否拍卖" clearable @keyup.enter="handleQuery" />
              </el-form-item>
              <el-form-item label="最终赔付金额" prop="finalPaymentAmount">
                <el-input v-model="queryParams.finalPaymentAmount" placeholder="请输入最终赔付金额" clearable @keyup.enter="handleQuery" />
              </el-form-item>
            </div>
            <div style="float: right">
              <el-form-item>
                <el-button type="success" icon="ArrowDown" @click="expandQuery">{{ isexpand ? '收起' : '展开' }}</el-button>
                <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
                <el-button icon="Refresh" @click="resetQuery">重置</el-button>
              </el-form-item>
            </div>
          </el-form>
        </el-card>
      </div>
    </transition>

    <el-card shadow="never">
      <template #header>
        <el-row :gutter="10" class="mb8">
          <el-col :span="1.5">
            <el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['system:main:add']">新增</el-button>
          </el-col>
          <el-col :span="1.5">
            <el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['system:main:edit']">修改</el-button>
          </el-col>
          <el-col :span="1.5">
            <el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['system:main:remove']"
              >删除</el-button
            >
          </el-col>
          <el-col :span="1.5">
            <el-upload
              v-model:file-list="fileList"
              class="upload-demo"
              action="https://run.mocky.io/v3/9d059bf9-4660-45f2-925d-ce80ad6c4d15"
              multiple
              :on-preview="handlePreview"
              :on-remove="handleRemove"
              :before-remove="beforeRemove"
              :limit="1"
              :on-exceed="handleExceed"
            >
              <el-button type="warning" plain icon="Upload" v-hasPermi="['system:main:add']">导入</el-button>
              <!-- <template #tip>
                <div class="el-upload__tip">jpg/png files with a size less than 500KB.</div>
              </template> -->
            </el-upload>
          </el-col>
          <el-col :span="1.5">
            <el-button type="info" plain icon="Download" @click="handleExport" v-hasPermi="['system:main:export']">导出</el-button>
          </el-col>
          <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
        </el-row>
      </template>

      <el-table v-loading="loading" border :data="mainList" @selection-change="handleSelectionChange">
        <el-table-column type="selection" width="55" align="center" />
        <el-table-column label="自增主键" align="center" prop="id" v-if="true" />
        <el-table-column label="案件号" align="center" prop="claimId" />
        <el-table-column label="业务来源" align="center" prop="businessSource" />
        <el-table-column label="京东报案号" align="center" prop="jdReportId" />
        <el-table-column label="报案时间" align="center" prop="reportTime" />
        <el-table-column label="出险时间" align="center" prop="occurrenceTime" />
        <el-table-column label="结案时间" align="center" prop="closeTime" />
        <el-table-column label="报案方式" align="center" prop="reportMethod" />
        <el-table-column label="履约类型" align="center" prop="performanceType" />
        <el-table-column label="物损程度" align="center" prop="damageDegree" />
        <el-table-column label="一级原因" align="center" prop="firstLevelReason" />
        <el-table-column label="二级原因" align="center" prop="secondLevelReason" />
        <el-table-column label="报案人" align="center" prop="reporter" />
        <el-table-column label="报案人电话" align="center" prop="reporterPhone" />
        <el-table-column label="寄件人" align="center" prop="sender" />
        <el-table-column label="寄件人电话" align="center" prop="senderPhone" />
        <el-table-column label="寄件地址" align="center" prop="senderAddress" />
        <el-table-column label="赔付方式" align="center" prop="paymentMethod" />
        <el-table-column label="保单号" align="center" prop="policyId" />
        <el-table-column label="保单起期" align="center" prop="policyStartTime" />
        <el-table-column label="保单止期" align="center" prop="policyEndTime" />
        <el-table-column label="延保订单号" align="center" prop="extendedWarrantyOrderId" />
        <el-table-column label="商家ID" align="center" prop="merchantId" />
        <el-table-column label="店铺ID" align="center" prop="shopId" />
        <el-table-column label="店铺名称" align="center" prop="shopName" />
        <el-table-column label="险种名称" align="center" prop="insuranceName" />
        <el-table-column label="主商品订单号" align="center" prop="mainOrderId" />
        <el-table-column label="主商品下单时间" align="center" prop="mainOrderCreateTime" />
        <el-table-column label="主商品出库时间" align="center" prop="mainOrderOutboundTime" />
        <el-table-column label="主商品完成时间" align="center" prop="mainOrderCompleteTime" />
        <el-table-column label="主商品名称" align="center" prop="mainCommodityName" />
        <el-table-column label="主商品SKU" align="center" prop="mainCommoditySku" />
        <el-table-column label="主商品IMEI设备标识" align="center" prop="mainCommodityImei" />
        <el-table-column label="主商品品牌" align="center" prop="brand" />
        <el-table-column label="主商品型号" align="center" prop="model" />
        <el-table-column label="主商品一级类目" align="center" prop="firstCategoryName" />
        <el-table-column label="主商品二级类目" align="center" prop="secondCategoryName" />
        <el-table-column label="主商品三级类目" align="center" prop="thirdCategoryName" />
        <el-table-column label="险种编码" align="center" prop="insuranceCode" />
        <el-table-column label="险种编码名称" align="center" prop="insuranceCodeName" />
        <el-table-column label="评星" align="center" prop="rating" />
        <el-table-column label="结案类型" align="center" prop="closeType" />
        <el-table-column label="交付商名称" align="center" prop="repairerName" />
        <el-table-column label="门店名称" align="center" prop="storeName" />
        <el-table-column label="派单时间" align="center" prop="dispatchTime" />
        <el-table-column label="接单时间" align="center" prop="acceptTime" />
        <el-table-column label="客户寄送时间" align="center" prop="customerSendTime" />
        <el-table-column label="快递单号" align="center" prop="expressNo" />
        <el-table-column label="接机时间" align="center" prop="receiveMachineTime" />
        <el-table-column label="方案提交时间" align="center" prop="planSubmitTime" />
        <el-table-column label="履约完成时间" align="center" prop="performanceCompleteTime" />
        <el-table-column label="采购渠道" align="center" prop="procurementChannel" />
        <el-table-column label="新机订单号" align="center" prop="newMachineOrderId" />
        <el-table-column label="归档时间" align="center" prop="fileTime" />
        <el-table-column label="结案状态" align="center" prop="closeStatus" />
        <el-table-column label="残值是否回收" align="center" prop="isResidualRecovered" />
        <el-table-column label="赔款是否支付" align="center" prop="isClaimPaid" />
        <el-table-column label="残值是否拍卖" align="center" prop="isResidualAuctioned" />
        <el-table-column label="最终赔付金额" align="center" prop="finalPaymentAmount" />
        <el-table-column label="报案日期" align="center" prop="reportDate" v-if="true" />
        <el-table-column label="操作" align="center" fixed="right" class-name="small-padding fixed-width">
          <template #default="scope">
            <el-tooltip content="修改" placement="top">
              <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['system:main:edit']"></el-button>
            </el-tooltip>
            <el-tooltip content="删除" placement="top">
              <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['system:main:remove']"></el-button>
            </el-tooltip>
          </template>
        </el-table-column>
      </el-table>

      <pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
    </el-card>
    <!-- 添加或修改理赔主对话框 -->
    <el-dialog :title="dialog.title" v-model="dialog.visible" width="90%" append-to-body>
      <el-form ref="mainFormRef" :model="form" :rules="rules" label-width="145" :inline="true" class="demo-form-inline">
        <el-form-item label="案件号" prop="claimId">
          <el-input v-model="form.claimId" placeholder="请输入案件号" />
        </el-form-item>
        <el-form-item label="业务来源" prop="businessSource">
          <el-input v-model="form.businessSource" placeholder="请输入业务来源" />
        </el-form-item>
        <el-form-item label="京东报案号" prop="jdReportId">
          <el-input v-model="form.jdReportId" placeholder="请输入京东报案号" />
        </el-form-item>
        <el-form-item label="报案时间" prop="reportTime">
          <el-input v-model="form.reportTime" placeholder="请输入报案时间" />
        </el-form-item>
        <el-form-item label="出险时间" prop="occurrenceTime">
          <el-input v-model="form.occurrenceTime" placeholder="请输入出险时间" />
        </el-form-item>
        <el-form-item label="结案时间" prop="closeTime">
          <el-input v-model="form.closeTime" placeholder="请输入结案时间" />
        </el-form-item>
        <el-form-item label="报案方式" prop="reportMethod">
          <el-input v-model="form.reportMethod" placeholder="请输入报案方式" />
        </el-form-item>
        <el-form-item label="物损程度" prop="damageDegree">
          <el-input v-model="form.damageDegree" placeholder="请输入物损程度" />
        </el-form-item>
        <el-form-item label="一级原因" prop="firstLevelReason">
          <el-input v-model="form.firstLevelReason" placeholder="请输入一级原因" />
        </el-form-item>
        <el-form-item label="二级原因" prop="secondLevelReason">
          <el-input v-model="form.secondLevelReason" placeholder="请输入二级原因" />
        </el-form-item>
        <el-form-item label="报案人" prop="reporter">
          <el-input v-model="form.reporter" placeholder="请输入报案人" />
        </el-form-item>
        <el-form-item label="报案人电话" prop="reporterPhone">
          <el-input v-model="form.reporterPhone" placeholder="请输入报案人电话" />
        </el-form-item>
        <el-form-item label="寄件人" prop="sender">
          <el-input v-model="form.sender" placeholder="请输入寄件人" />
        </el-form-item>
        <el-form-item label="寄件人电话" prop="senderPhone">
          <el-input v-model="form.senderPhone" placeholder="请输入寄件人电话" />
        </el-form-item>
        <el-form-item label="寄件地址" prop="senderAddress">
          <el-input v-model="form.senderAddress" placeholder="请输入寄件地址" />
        </el-form-item>
        <el-form-item label="赔付方式" prop="paymentMethod">
          <el-input v-model="form.paymentMethod" placeholder="请输入赔付方式" />
        </el-form-item>
        <el-form-item label="保单号" prop="policyId">
          <el-input v-model="form.policyId" placeholder="请输入保单号" />
        </el-form-item>
        <el-form-item label="保单起期" prop="policyStartTime">
          <el-input v-model="form.policyStartTime" placeholder="请输入保单起期" />
        </el-form-item>
        <el-form-item label="保单止期" prop="policyEndTime">
          <el-input v-model="form.policyEndTime" placeholder="请输入保单止期" />
        </el-form-item>
        <el-form-item label="延保订单号" prop="extendedWarrantyOrderId">
          <el-input v-model="form.extendedWarrantyOrderId" placeholder="请输入延保订单号" />
        </el-form-item>
        <el-form-item label="商家ID" prop="merchantId">
          <el-input v-model="form.merchantId" placeholder="请输入商家ID" />
        </el-form-item>
        <el-form-item label="店铺ID" prop="shopId">
          <el-input v-model="form.shopId" placeholder="请输入店铺ID" />
        </el-form-item>
        <el-form-item label="店铺名称" prop="shopName">
          <el-input v-model="form.shopName" placeholder="请输入店铺名称" />
        </el-form-item>
        <el-form-item label="险种名称" prop="insuranceName">
          <el-input v-model="form.insuranceName" placeholder="请输入险种名称" />
        </el-form-item>
        <el-form-item label="主商品订单号" prop="mainOrderId">
          <el-input v-model="form.mainOrderId" placeholder="请输入主商品订单号" />
        </el-form-item>
        <el-form-item label="主商品下单时间" prop="mainOrderCreateTime">
          <el-input v-model="form.mainOrderCreateTime" placeholder="请输入主商品下单时间" />
        </el-form-item>
        <el-form-item label="主商品出库时间" prop="mainOrderOutboundTime">
          <el-input v-model="form.mainOrderOutboundTime" placeholder="请输入主商品出库时间" />
        </el-form-item>
        <el-form-item label="主商品完成时间" prop="mainOrderCompleteTime">
          <el-input v-model="form.mainOrderCompleteTime" placeholder="请输入主商品完成时间" />
        </el-form-item>
        <el-form-item label="主商品名称" prop="mainCommodityName">
          <el-input v-model="form.mainCommodityName" placeholder="请输入主商品名称" />
        </el-form-item>
        <el-form-item label="主商品SKU" prop="mainCommoditySku">
          <el-input v-model="form.mainCommoditySku" placeholder="请输入主商品SKU" />
        </el-form-item>
        <el-form-item label="主商品IMEI设备标识" prop="mainCommodityImei">
          <el-input v-model="form.mainCommodityImei" placeholder="请输入主商品IMEI设备标识" />
        </el-form-item>
        <el-form-item label="主商品品牌" prop="brand">
          <el-input v-model="form.brand" placeholder="请输入主商品品牌" />
        </el-form-item>
        <el-form-item label="主商品型号" prop="model">
          <el-input v-model="form.model" placeholder="请输入主商品型号" />
        </el-form-item>
        <el-form-item label="主商品一级类目" prop="firstCategoryName">
          <el-input v-model="form.firstCategoryName" placeholder="请输入主商品一级类目" />
        </el-form-item>
        <el-form-item label="主商品二级类目" prop="secondCategoryName">
          <el-input v-model="form.secondCategoryName" placeholder="请输入主商品二级类目" />
        </el-form-item>
        <el-form-item label="主商品三级类目" prop="thirdCategoryName">
          <el-input v-model="form.thirdCategoryName" placeholder="请输入主商品三级类目" />
        </el-form-item>
        <el-form-item label="险种编码" prop="insuranceCode">
          <el-input v-model="form.insuranceCode" placeholder="请输入险种编码" />
        </el-form-item>
        <el-form-item label="险种编码名称" prop="insuranceCodeName">
          <el-input v-model="form.insuranceCodeName" placeholder="请输入险种编码名称" />
        </el-form-item>
        <el-form-item label="评星" prop="rating">
          <el-input v-model="form.rating" placeholder="请输入评星" />
        </el-form-item>
        <el-form-item label="交付商名称" prop="repairerName">
          <el-input v-model="form.repairerName" placeholder="请输入交付商名称" />
        </el-form-item>
        <el-form-item label="门店名称" prop="storeName">
          <el-input v-model="form.storeName" placeholder="请输入门店名称" />
        </el-form-item>
        <el-form-item label="派单时间" prop="dispatchTime">
          <el-input v-model="form.dispatchTime" placeholder="请输入派单时间" />
        </el-form-item>
        <el-form-item label="接单时间" prop="acceptTime">
          <el-input v-model="form.acceptTime" placeholder="请输入接单时间" />
        </el-form-item>
        <el-form-item label="客户寄送时间" prop="customerSendTime">
          <el-input v-model="form.customerSendTime" placeholder="请输入客户寄送时间" />
        </el-form-item>
        <el-form-item label="快递单号" prop="expressNo">
          <el-input v-model="form.expressNo" placeholder="请输入快递单号" />
        </el-form-item>
        <el-form-item label="接机时间" prop="receiveMachineTime">
          <el-input v-model="form.receiveMachineTime" placeholder="请输入接机时间" />
        </el-form-item>
        <el-form-item label="方案提交时间" prop="planSubmitTime">
          <el-input v-model="form.planSubmitTime" placeholder="请输入方案提交时间" />
        </el-form-item>
        <el-form-item label="履约完成时间" prop="performanceCompleteTime">
          <el-input v-model="form.performanceCompleteTime" placeholder="请输入履约完成时间" />
        </el-form-item>
        <el-form-item label="采购渠道" prop="procurementChannel">
          <el-input v-model="form.procurementChannel" placeholder="请输入采购渠道" />
        </el-form-item>
        <el-form-item label="新机订单号" prop="newMachineOrderId">
          <el-input v-model="form.newMachineOrderId" placeholder="请输入新机订单号" />
        </el-form-item>
        <el-form-item label="归档时间" prop="fileTime">
          <el-input v-model="form.fileTime" placeholder="请输入归档时间" />
        </el-form-item>
        <el-form-item label="残值是否回收" prop="isResidualRecovered">
          <el-input v-model="form.isResidualRecovered" placeholder="请输入残值是否回收" />
        </el-form-item>
        <el-form-item label="赔款是否支付" prop="isClaimPaid">
          <el-input v-model="form.isClaimPaid" placeholder="请输入赔款是否支付" />
        </el-form-item>
        <el-form-item label="残值是否拍卖" prop="isResidualAuctioned">
          <el-input v-model="form.isResidualAuctioned" placeholder="请输入残值是否拍卖" />
        </el-form-item>
        <el-form-item label="最终赔付金额" prop="finalPaymentAmount">
          <el-input v-model="form.finalPaymentAmount" placeholder="请输入最终赔付金额" />
        </el-form-item>
      </el-form>
      <template #footer>
        <div class="dialog-footer">
          <el-button :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button>
          <el-button @click="cancel">取 消</el-button>
        </div>
      </template>
    </el-dialog>
  </div>
</template>

<script setup name="Main" lang="ts">
import { listMain, getMain, delMain, addMain, updateMain } from '@/api/system/main';
import { MainVO, MainQuery, MainForm } from '@/api/system/main/types';

const { proxy } = getCurrentInstance() as ComponentInternalInstance;

const mainList = ref<MainVO[]>([]);
const buttonLoading = ref(false);
const loading = ref(true);
const showSearch = ref(true);
const ids = ref<Array<string | number>>([]);
const single = ref(true);
const multiple = ref(true);
const total = ref(0);

const queryFormRef = ref<ElFormInstance>();
const mainFormRef = ref<ElFormInstance>();

const dialog = reactive<DialogOption>({
  visible: false,
  title: ''
});

const isexpand = ref(false);

const initFormData: MainForm = {
  id: undefined,
  claimId: undefined,
  businessSource: undefined,
  jdReportId: undefined,
  reportTime: undefined,
  occurrenceTime: undefined,
  closeTime: undefined,
  reportMethod: undefined,
  performanceType: undefined,
  damageDegree: undefined,
  firstLevelReason: undefined,
  secondLevelReason: undefined,
  reporter: undefined,
  reporterPhone: undefined,
  sender: undefined,
  senderPhone: undefined,
  senderAddress: undefined,
  paymentMethod: undefined,
  policyId: undefined,
  policyStartTime: undefined,
  policyEndTime: undefined,
  extendedWarrantyOrderId: undefined,
  merchantId: undefined,
  shopId: undefined,
  shopName: undefined,
  insuranceName: undefined,
  mainOrderId: undefined,
  mainOrderCreateTime: undefined,
  mainOrderOutboundTime: undefined,
  mainOrderCompleteTime: undefined,
  mainCommodityName: undefined,
  mainCommoditySku: undefined,
  mainCommodityImei: undefined,
  brand: undefined,
  model: undefined,
  firstCategoryName: undefined,
  secondCategoryName: undefined,
  thirdCategoryName: undefined,
  insuranceCode: undefined,
  insuranceCodeName: undefined,
  rating: undefined,
  closeType: undefined,
  repairerName: undefined,
  storeName: undefined,
  dispatchTime: undefined,
  acceptTime: undefined,
  customerSendTime: undefined,
  expressNo: undefined,
  receiveMachineTime: undefined,
  planSubmitTime: undefined,
  performanceCompleteTime: undefined,
  procurementChannel: undefined,
  newMachineOrderId: undefined,
  fileTime: undefined,
  closeStatus: undefined,
  isResidualRecovered: undefined,
  isClaimPaid: undefined,
  isResidualAuctioned: undefined,
  finalPaymentAmount: undefined,
  reportDate: undefined
};
const data = reactive<PageData<MainForm, MainQuery>>({
  form: { ...initFormData },
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    claimId: undefined,
    businessSource: undefined,
    jdReportId: undefined,
    reportTime: undefined,
    occurrenceTime: undefined,
    closeTime: undefined,
    reportMethod: undefined,
    performanceType: undefined,
    damageDegree: undefined,
    firstLevelReason: undefined,
    secondLevelReason: undefined,
    reporter: undefined,
    reporterPhone: undefined,
    sender: undefined,
    senderPhone: undefined,
    senderAddress: undefined,
    paymentMethod: undefined,
    policyId: undefined,
    policyStartTime: undefined,
    policyEndTime: undefined,
    extendedWarrantyOrderId: undefined,
    merchantId: undefined,
    shopId: undefined,
    shopName: undefined,
    insuranceName: undefined,
    mainOrderId: undefined,
    mainOrderCreateTime: undefined,
    mainOrderOutboundTime: undefined,
    mainOrderCompleteTime: undefined,
    mainCommodityName: undefined,
    mainCommoditySku: undefined,
    mainCommodityImei: undefined,
    brand: undefined,
    model: undefined,
    firstCategoryName: undefined,
    secondCategoryName: undefined,
    thirdCategoryName: undefined,
    insuranceCode: undefined,
    insuranceCodeName: undefined,
    rating: undefined,
    closeType: undefined,
    repairerName: undefined,
    storeName: undefined,
    dispatchTime: undefined,
    acceptTime: undefined,
    customerSendTime: undefined,
    expressNo: undefined,
    receiveMachineTime: undefined,
    planSubmitTime: undefined,
    performanceCompleteTime: undefined,
    procurementChannel: undefined,
    newMachineOrderId: undefined,
    fileTime: undefined,
    closeStatus: undefined,
    isResidualRecovered: undefined,
    isClaimPaid: undefined,
    isResidualAuctioned: undefined,
    finalPaymentAmount: undefined,
    params: {}
  },
  rules: {
    id: [{ required: true, message: '自增主键不能为空', trigger: 'blur' }],
    claimId: [{ required: true, message: '案件号不能为空', trigger: 'blur' }],
    reportDate: [{ required: true, message: '报案日期不能为空', trigger: 'blur' }]
  }
});

const { queryParams, form, rules } = toRefs(data);

/** 查询理赔主列表 */
const getList = async () => {
  loading.value = true;
  const res = await listMain(queryParams.value);
  mainList.value = res.rows;
  total.value = res.total;
  loading.value = false;
};

/** 取消按钮 */
const cancel = () => {
  reset();
  dialog.visible = false;
};

/** 表单重置 */
const reset = () => {
  form.value = { ...initFormData };
  mainFormRef.value?.resetFields();
};
/** 展开更多按钮操作 */
const expandQuery = () => {
  isexpand.value = !isexpand.value;
};
/** 搜索按钮操作 */
const handleQuery = () => {
  queryParams.value.pageNum = 1;
  getList();
};

/** 重置按钮操作 */
const resetQuery = () => {
  queryFormRef.value?.resetFields();
  handleQuery();
};

/** 多选框选中数据 */
const handleSelectionChange = (selection: MainVO[]) => {
  ids.value = selection.map((item) => item.id);
  single.value = selection.length != 1;
  multiple.value = !selection.length;
};

/** 新增按钮操作 */
const handleAdd = () => {
  reset();
  dialog.visible = true;
  dialog.title = '添加理赔主';
};

/** 修改按钮操作 */
const handleUpdate = async (row?: MainVO) => {
  reset();
  const _id = row?.id || ids.value[0];
  const res = await getMain(_id);
  Object.assign(form.value, res.data);
  dialog.visible = true;
  dialog.title = '修改理赔主';
};

/** 提交按钮 */
const submitForm = () => {
  mainFormRef.value?.validate(async (valid: boolean) => {
    if (valid) {
      buttonLoading.value = true;
      if (form.value.id) {
        await updateMain(form.value).finally(() => (buttonLoading.value = false));
      } else {
        await addMain(form.value).finally(() => (buttonLoading.value = false));
      }
      proxy?.$modal.msgSuccess('操作成功');
      dialog.visible = false;
      await getList();
    }
  });
};

/** 删除按钮操作 */
const handleDelete = async (row?: MainVO) => {
  const _ids = row?.id || ids.value;
  await proxy?.$modal.confirm('是否确认删除理赔主编号为"' + _ids + '"的数据项？').finally(() => (loading.value = false));
  await delMain(_ids);
  proxy?.$modal.msgSuccess('删除成功');
  await getList();
};

/** 导出按钮操作 */
const handleExport = () => {
  proxy?.download(
    'system/main/export',
    {
      ...queryParams.value
    },
    `main_${new Date().getTime()}.xlsx`
  );
};

onMounted(() => {
  getList();
});
</script>
<style scoped lang="scss">
:deep(.el-form--inline .el-form-item) {
  margin-right: 25px !important;
}
.demo-form-inline {
  :deep(.el-form-item) {
    vertical-align: baseline !important;
  }
  :deep(.el-input) {
    width: 370px !important;
  }
  :deep(.el-textarea) {
    width: 370px !important;
  }
  :deep(.el-textarea__inner) {
    min-height: 100px !important;
  }
}
</style>
